<?php 




$nrOfOperations = pow(10,15);
$flops = pow(10,10);
$latency = 2 * pow(10, -7);
$start = 10;
$end = 110000;
$step = 990;
$sequential = $nrOfOperations / $flops;



$t = sqrt(2 * ($nrOfOperations / ($flops / $latency)));



// $n = $t / $latency;
// echo $n . '<br>'; 
// $parallel = $nrOfOperations / ($n * $flops);
// $parallelLatency = $n * $latency + $parallel;
// $speedUp = $sequential / ($parallelLatency);
// $sum = $parallelLatency + $sequential;

// echo $sum;
// die();
?>

<p>Initial: <?php echo $sequential; ?> sec</p>
<table>
	<tr>
		<th>Nr of PC</th>
		<th>Parallel time</th>
		<th>Speedup</th>
		<th>Total</th>
		<th>Difference</th>
	</tr>
<?php $prev = null; ?>
<?php for ($i = $start; $i <= $end; $i += $step):?>
<?php $parallel = $nrOfOperations / ($i * $flops);
	$parallelLatency = $i * $latency + $parallel;
	$speedUp = $sequential / ($parallelLatency);
	$sum = $parallelLatency + $sequential; ?>
	<tr>
		<td><?php echo $i; ?></td>
		<td><?php echo $parallelLatency; ?></td>
		<td><?php echo $speedUp; ?></td>
		<td><?php echo $parallelLatency + $sequential; ?></td>
		<td>
		<?php if ($prev != null): ?>
			<?php echo $prev - $sum; ?>
		<?php endif; ?>
		</td>
	</tr>
	
	<?php $prev = $sum; ?>

<?php endfor; ?>

</table>